package com.lws.omapicompat

import android.content.Context
import android.os.Build
import com.lws.omapicompat.google.SEServiceNew
import com.lws.omapicompat.simalliance.SEServiceOld
import java.util.concurrent.Executor

interface SEServiceCompat {

    fun getReaders(): Array<ReaderCompat>

    fun getUiccReader(slotNumber: Int): ReaderCompat

    fun getVersion(): String

    fun isConnected(): Boolean


    fun shutdown()

    interface OnConnectedListener {
        fun onConnected()
    }

    companion object {

        @JvmStatic
        fun get(
            context: Context,
            executor: Executor,
            listener: OnConnectedListener
        ): SEServiceCompat {
            return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
                SEServiceNew(context, executor, listener)
            } else {
                SEServiceOld(context, executor, listener)
            }
        }
    }
}